<?php

namespace Modules\Shop\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CategoryRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        //获取路由参数中的值
        $id = $this->route('category');
        return [
            'cname' => 'required|unique:categories,cname,' . $id,
        ];
    }
    public function messages(){
        return[
            'cname.required'=>'分类名称不能为空'
        ];
    }
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
